-- property_immunity
-- create by dengc
-- 免疫道具的扣血或者扣蓝的效果

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 使用道具时触发
    trigger = function(who, prop, arg)
        local value = arg["value"];
        if type(value) ~= "number" then
            return value;
        end

        local classId = arg["class_id"];
        if not classId then
            return value;
        end

        -- 不是期望的道具
        if prop[2] ~= classId then
            return value;
        end

        -- 概率免疫
        if DungeonM.getRandSeed("property_damage") % 1000 < prop[3] then
            return 0;
        end

        return value;
    end,

    record = function(target, prop, path)
        return false;
    end 
};
